package view;

import model.Author;
import model.SearchSpecifications.SearchCategory;
import model.Work.WorkCategory;

class HtmlFactory {

	static String createPageHead(String realPath) {
		/* @formatter:off */
		String head = ""
		+ "<head>"
		+ "	<meta charset='UTF-8'>"
		+ "	<link rel='stylesheet' type='text/css' href='styles/workshared.css'>"
		+ "</head>";
		/* @formatter:on */
		return head;
	}

	static String createPageFooter() {
		String footer = "";
		return footer;
	}

	static String createPageHeader(Author author) {
		/* @formatter:off */
		String header = ""
		+ "<div id='header'>"
		+ "		<img src='images/logoIFSP.png' width='300' height='150'>";
		/* @formatter:on */
		if (author == null) {
			/* @formatter:off */
//			header += ""
//			+ "	<div id='loginContainer'>"
//			+ "		<form action='Controller' method='POST'>"
//			+ "			Username: <input type='text' name='username'>"
//			+ "			Password: <input type='password' name='password'>"
//			+ "			<input type='submit' name='button' value='Login'>"
//			+ "		</form>"
//			+ "		<form action='Controller' method='GET'>"
//			+ "			<input type='submit' name='button' value='Registrar'>"
//			+ "		</form>"
//			+ "	</div>";
			/* @formatter:on */
		} else {
			/* @formatter:off */
			header += ""
			+ "	<div id='loggedContainer'>"
			+ "		Seja bem-vindo(a), "+author.getFirstName()+"!"
//			+ "		<a href='Controller?button=Logout'>Sair</a>"
			+ "	</div>";
			/* @formatter:on */
		}

		/* @formatter:off */
		header += "	<div id='menu'>";
		header+= "		<a href='Controller?button=Pesquisar'>Pesquisar</a>";

		/* @formatter:on */
		if (author == null) {
			header += "	<a href='Controller?button=Registrar'>Registrar</a>"
					+ "	<a href='Controller?button=Login'>Login</a>";
		} else {
			header += "	<a href='Controller?button=Submeter'>Submeter</a>"
					+ "	<a href='Controller?button=Logout'>Logout</a>";
		}
		/* @formatter:off */
		header +="	</div>	"
		+ "</div>";
		/* @formatter:on */

		return header;
	}

	static String createCategoryCombo(WorkCategory initialCategory) {
		/* @formatter:off */
		String combo = ""
		+ "<select name='workCategory' value='"+initialCategory.ordinal()+"'>";
		/* @formatter:on */
		for (WorkCategory c : WorkCategory.values()) {
			combo += "" + "<option value='" + c.ordinal() + "'>" + c.toString() + "</option>";
		}
		/* @formatter:off */
		combo += ""
		+ "</select>";
		/* @formatter:on */

		return combo;
	}

	static String createErrorMessage(String message) {
		return "<div class='errorMessage'>" + message + "</div>";
	}

	static String createSuccessMessage(String message) {
		return "<div class='successMessage'>" + message + "</div>";
	}

	static String createCategoryCombo(SearchCategory category) {
		/* @formatter:off */
		String searchCombo = ""
		+ "<select name='searchCategory' value='"+category.ordinal()+"'>";
		/* @formatter:on */
		for (SearchCategory c : SearchCategory.values()) {
			searchCombo += "<option value='" + c.ordinal() + "'>" + c.toString() + "</option>";
		}
		/* @formatter:off */
		searchCombo += ""
		+ "</select>";
		
		/* @formatter:on */
		return searchCombo;
	}
}
